package gui;

import game.Game;

import java.awt.SystemColor;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.SwingConstants;

public class GameFinished extends JFrame implements ActionListener{
	
	private Game game;
	
	public GameFinished(String winner, Game pGame){
		pGame = null;
		game = null;
		
		setTitle("Spiel Beendet");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 130);
		JPanel contentPane = new JPanel();
		contentPane.setBackground(SystemColor.inactiveCaption);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblWinner = new JLabel(winner);
		lblWinner.setHorizontalAlignment(SwingConstants.CENTER);
		lblWinner.setBounds(7, 11, 420, 40);
		lblWinner.setFont(new Font("Tahoma", Font.PLAIN, 28));
		contentPane.add(lblWinner);
		
		JButton btnNewGame = new JButton("Neues Spiel");
		btnNewGame.setBounds(10, 62, 200, 23);
		contentPane.add(btnNewGame);
		btnNewGame.setActionCommand("NewGame");
		btnNewGame.addActionListener(this);
		
		JButton btnEnd = new JButton("Beenden");
		btnEnd.setBounds(224, 62, 200, 23);
		contentPane.add(btnEnd);
		btnEnd.setActionCommand("End");
		btnEnd.addActionListener(this);
		
		setVisible(true);
	}
	
	public void actionPerformed(ActionEvent arg0){
		if(arg0.getActionCommand().equals("NewGame")){
			setVisible(false);
			game = new Game();
		}
		else if(arg0.getActionCommand().equals("End")){
			System.exit(0);
		}
	}
}
